// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
// 引入vue-table-with-tree-grid
import TreeTable from 'vue-table-with-tree-grid'
Vue.component('tree-table', TreeTable)
// 引入elememnt-ui
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI)

// 引入全局css
import "./assets/css/global.css"
// 引入icon
import "./assets/fonts/iconfont.css"

// 引入axios --发请求
import axios from "axios";
axios.defaults.baseURL = "/api/"
// 请求拦截
axios.interceptors.request.use(config => {
  // console.log('config', config);
  config.headers.Authorization = window.sessionStorage.getItem('token');
  return config;
})
Vue.prototype.$http = axios;

// 导入ele的弹框提示组件
import { Message } from 'element-ui';
Vue.prototype.$message = Message

// 过滤器
Vue.filter('dateFormat', function (time) {
  const dt = new Date(time)
  const y = dt.getFullYear();
  // padStart 补全开头--(总共几位,补的str)
  const m = (dt.getMonth() + 1 + '').padStart(2, '0')
  const d = (dt.getDate() + '').padStart(2, '0')

  const hh = (dt.getHours() + '').padStart(2, '0')
  const mm = (dt.getMinutes() + '').padStart(2, '0')
  const ss = (dt.getSeconds() + '').padStart(2, '0')
  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})
// https://github.com/surmon-china/vue-quill-editor
import VueQuillEditor from 'vue-quill-editor'
// require styles
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'

Vue.use(VueQuillEditor)

Vue.config.productionTip = false
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
